<template>
    <div :key="key">
        <Drawer title="救助业务历史" :closable="false" v-model="visible" :width="width">
            <div style="margin-top:10px ">
                <vxe-table border
                           resizable
                           row-id="id"
                           :row-key="true"
                           show-overflow="tooltip"
                           highlight-hover-row
                           align="center"
                           header-align="center"
                           ref="xTree"
                           :loading="Loading"
                           :data="tableData">
                    <vxe-table-column field="azcp0003" title="申请人" align="center" width="100"/>
                    <vxe-table-column field="azcp0001" title="身份证号码" align="center" width="200"/>
                    <vxe-table-column field="ssca0016_name" title="业务类型" align="center" width="200"/>
                    <vxe-table-column field="create_date" title="受理时间" align="center" width="200" :formatter="renderTime"/>
                    <vxe-table-column field="TYPE" title="数据状态" align="center" width="200" :formatter="formatType"/>
                    <vxe-table-column field="ssca0075" title="是否不予受理" align="center" width="200"
                                      :formatter="renderYesOrNo"/>
                    <vxe-table-column field="ssca0056" title="是否审批终止" align="center" width="200"
                                      :formatter="renderYesOrNo"/>
                    <vxe-table-column field="transfer" title="是否完成迁移" align="center" width="200"
                                      :formatter="renderYesOrNo"/>
                    <vxe-table-column field="splx" title="审批类别" align="center" width="200"/>
                    <vxe-table-column field="ssca0026" title="救助金总额" align="center" width="200"/>
                    <vxe-table-column title="操作" align="center" width="140" fixed="right">
                        <template #default="{row}">
                            <Button type="default" @click="detail(row)" v-if="row.TYPE=='100'">查看</Button>
                        </template>
                    </vxe-table-column>
                </vxe-table>
            </div>
        </Drawer>
        <application-modal ref="modal"/>
    </div>
</template>

<script>
    import applicationModal from '../../db_application_history/applicationModal'
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import {postAction} from '@/api/request'

    export default {
        name: "history-drawer",
        mixins: [CommonMixin],
        components: {applicationModal},
        data() {
            return {
                visible: false,
                model: {},
                width: 800,
                Loading: true,
                key: "",
                tableData: []
            }
        },
        methods: {
            edit(row, width, ssca0002Type) {
                this.tableData = [];
                this.visible = true
                this.model = Object.assign({}, row);
                this.width = width;
                this.tableData = [];
                this.Loading = true;
                row.ssca0002Type = ssca0002Type;
                this.load(row);
            },
            searchDetail() {
                var row = this.model;
                row.processinstid = row.ywgl004;
                var width = this.width;
                this.$refs.modal.edit(row);
                this.$refs.modal.width = width + 40;
                this.$refs.modal.key = this.uuid();
            },
            detail(row) {
                row.processinstid = row.ywgl004;
                row.ss12001Id = row.id;
                var width = this.width;
                this.$refs.modal.edit(row);
                this.$refs.modal.width = width + 40;
                this.$refs.modal.key = this.uuid();
            },
            load(row) {
                var that = this;
                postAction("/api/ac/subsistence/ss12001HistoryService/detail", row).then((res) => {
                    if (res.data.errcode != 0) {
                        this.$Message.error(res.data.errmsg);
                    } else {
                        that.tableData = res.data.data;
                    }
                }).finally(() => {
                    that.Loading = false;
                })
            },
            formatType(h) {
                var value = h.cellValue;
                if (value == "100") {
                    return "填报审批完成";
                } else if (value == "200") {
                    return "历史数据导入";
                } else if (value == "300") {
                    return "推送审批完成";
                } else if (value == "400" || value == "500") {
                    return "填报审批未提交";
                } else {
                    return "填报正在审批";
                }
            }
        }
    }
</script>

<style scoped>

</style>
